package yunjiao.designpatterns.state;

import lombok.Getter;
import lombok.Setter;

/**
 * TODO
 *
 * @author yangyunjiao
 */
@Getter
@Setter
public class Exception implements ShipmentState {

    protected String exceptionMsg;

    public Exception(String exceptionMsg) {
        super();
        this.exceptionMsg = exceptionMsg;
    }

    @Override

    public void processShipment(ShipmentContext context) {
        Shipment shipment = context.getShipment();
        System.out.printf("Order#'%s' for '%s' has status '%s (%s)'.\nDelivery Address is '%s'\n",
                shipment.getOrderNumber(), shipment.getOrderItem(), name(), exceptionMsg,
                shipment.getDeliveryAddress());
        System.out.println("--------------------------------------------------------------");

        context.setCurrentState(new Returned());
    }


    @Override

    public String name() {
        return "Exception";
    }
}
